package com.shadow.cloud.test.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/resource")
public class ResourceController {

    /**
     * 查询资源
     */
    @PreAuthorize("hasAuthority('test:get')")
    @GetMapping
    public String doSelect() {
        return "Select Resource ok";
    }

    /**
     * 创建资源
     */
    @PreAuthorize("hasAuthority('test:post')")
    @PostMapping
    public String doCreate() {
        return "Create Resource OK";
    }

    /**
     * 修改资源
     */
    @PreAuthorize("hasAuthority('test:put')")
    @PutMapping
    public String doUpdate() {
        return "Update Resource OK";
    }

    /**
     * 删除资源
     */
    @DeleteMapping
    public String doDelete() {
        return "Delete resource ok";
    }
}
